/* tslint:disable */
/* eslint-disable */
/*
Humanloop API

The Humanloop API allows you to interact with Humanloop from your product or service.

You can do this through HTTP requests from any language or via our official Python or TypeScript SDK.

To install the official [Python SDK](https://pypi.org/project/humanloop/), run the following command:

```bash
pip install humanloop
```

To install the official [TypeScript SDK](https://www.npmjs.com/package/humanloop), run the following command:

```bash
npm i humanloop
```

---

Guides and further details about key concepts can be found in [our docs](https://docs.humanloop.com/).

The version of the OpenAPI document: 4.0.1


NOTE: This file is auto generated by Konfig (https://konfigthis.com).
*/

import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import { Configuration } from '../configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, isBrowser } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { CompletionDeployedRequest } from '../models';
// @ts-ignore
import { CompletionExperimentRequest } from '../models';
// @ts-ignore
import { CompletionModelConfigRequest } from '../models';
// @ts-ignore
import { CompletionRequest } from '../models';
// @ts-ignore
import { CompletionResponse } from '../models';
// @ts-ignore
import { HTTPValidationError } from '../models';
// @ts-ignore
import { ModelConfigCompletionRequest } from '../models';
// @ts-ignore
import { ProviderApiKeys } from '../models';
import { paginate } from "../pagination/paginate";
import type * as buffer from "buffer"
import { requestBeforeHook } from '../requestBeforeHook';
/**
 * CompletionsApi - axios parameter creator
 * @export
 */
export const CompletionsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create a completion by providing details of the model configuration in the request.
         * @summary Create
         * @param {CompletionRequest} completionRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        create: async (completionRequest: CompletionRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'completionRequest' is not null or undefined
            assertParamExists('create', 'completionRequest', completionRequest)
            const localVarPath = `/completion`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: completionRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/completion',
                httpMethod: 'POST'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(completionRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Create a completion using the project\'s active deployment.  The active deployment can be a specific model configuration or an experiment.
         * @summary Completion Deployed
         * @param {CompletionDeployedRequest} completionDeployedRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createDeployed: async (completionDeployedRequest: CompletionDeployedRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'completionDeployedRequest' is not null or undefined
            assertParamExists('createDeployed', 'completionDeployedRequest', completionDeployedRequest)
            const localVarPath = `/completion-deployed`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: completionDeployedRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/completion-deployed',
                httpMethod: 'POST'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(completionDeployedRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Create a completion for a specific experiment.
         * @summary Completion Experiment
         * @param {CompletionExperimentRequest} completionExperimentRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createExperiment: async (completionExperimentRequest: CompletionExperimentRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'completionExperimentRequest' is not null or undefined
            assertParamExists('createExperiment', 'completionExperimentRequest', completionExperimentRequest)
            const localVarPath = `/completion-experiment`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: completionExperimentRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/completion-experiment',
                httpMethod: 'POST'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(completionExperimentRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Create a completion for a specific model configuration.
         * @summary Completion Model Config
         * @param {CompletionModelConfigRequest} completionModelConfigRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createModelConfig: async (completionModelConfigRequest: CompletionModelConfigRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'completionModelConfigRequest' is not null or undefined
            assertParamExists('createModelConfig', 'completionModelConfigRequest', completionModelConfigRequest)
            const localVarPath = `/completion-model-config`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions: AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = configuration && !isBrowser() ? { "User-Agent": configuration.userAgent } : {} as any;
            const localVarQueryParameter = {} as any;

            // authentication APIKeyHeader required
            await setApiKeyToObject({ object: localVarHeaderParameter, key: "X-API-KEY", keyParamName: "xAPIKEY", configuration })

    
            localVarHeaderParameter['Content-Type'] = 'application/json';


            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            requestBeforeHook({
                requestBody: completionModelConfigRequest,
                queryParameters: localVarQueryParameter,
                requestConfig: localVarRequestOptions,
                path: localVarPath,
                configuration,
                pathTemplate: '/completion-model-config',
                httpMethod: 'POST'
            });
            localVarRequestOptions.data = serializeDataIfNeeded(completionModelConfigRequest, localVarRequestOptions, configuration)

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * CompletionsApi - functional programming interface
 * @export
 */
export const CompletionsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = CompletionsApiAxiosParamCreator(configuration)
    return {
        /**
         * Create a completion by providing details of the model configuration in the request.
         * @summary Create
         * @param {CompletionsApiCreateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async create(requestParameters: CompletionsApiCreateRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CompletionResponse>> {
            const completionRequest: CompletionRequest = {
                project: requestParameters.project,
                project_id: requestParameters.project_id,
                session_id: requestParameters.session_id,
                session_reference_id: requestParameters.session_reference_id,
                parent_id: requestParameters.parent_id,
                parent_reference_id: requestParameters.parent_reference_id,
                inputs: requestParameters.inputs,
                source: requestParameters.source,
                metadata: requestParameters.metadata,
                source_datapoint_id: requestParameters.source_datapoint_id,
                provider_api_keys: requestParameters.provider_api_keys,
                num_samples: requestParameters.num_samples,
                logprobs: requestParameters.logprobs,
                stream: requestParameters.stream,
                suffix: requestParameters.suffix,
                seed: requestParameters.seed,
                user: requestParameters.user,
                model_config: requestParameters.model_config
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.create(completionRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Create a completion using the project\'s active deployment.  The active deployment can be a specific model configuration or an experiment.
         * @summary Completion Deployed
         * @param {CompletionsApiCreateDeployedRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createDeployed(requestParameters: CompletionsApiCreateDeployedRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CompletionResponse>> {
            const completionDeployedRequest: CompletionDeployedRequest = {
                project: requestParameters.project,
                project_id: requestParameters.project_id,
                session_id: requestParameters.session_id,
                session_reference_id: requestParameters.session_reference_id,
                parent_id: requestParameters.parent_id,
                parent_reference_id: requestParameters.parent_reference_id,
                inputs: requestParameters.inputs,
                source: requestParameters.source,
                metadata: requestParameters.metadata,
                source_datapoint_id: requestParameters.source_datapoint_id,
                provider_api_keys: requestParameters.provider_api_keys,
                num_samples: requestParameters.num_samples,
                logprobs: requestParameters.logprobs,
                stream: requestParameters.stream,
                suffix: requestParameters.suffix,
                seed: requestParameters.seed,
                user: requestParameters.user,
                environment: requestParameters.environment
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.createDeployed(completionDeployedRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Create a completion for a specific experiment.
         * @summary Completion Experiment
         * @param {CompletionsApiCreateExperimentRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createExperiment(requestParameters: CompletionsApiCreateExperimentRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CompletionResponse>> {
            const completionExperimentRequest: CompletionExperimentRequest = {
                project: requestParameters.project,
                project_id: requestParameters.project_id,
                session_id: requestParameters.session_id,
                session_reference_id: requestParameters.session_reference_id,
                parent_id: requestParameters.parent_id,
                parent_reference_id: requestParameters.parent_reference_id,
                inputs: requestParameters.inputs,
                source: requestParameters.source,
                metadata: requestParameters.metadata,
                source_datapoint_id: requestParameters.source_datapoint_id,
                provider_api_keys: requestParameters.provider_api_keys,
                num_samples: requestParameters.num_samples,
                logprobs: requestParameters.logprobs,
                stream: requestParameters.stream,
                suffix: requestParameters.suffix,
                seed: requestParameters.seed,
                user: requestParameters.user,
                experiment_id: requestParameters.experiment_id
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.createExperiment(completionExperimentRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
        /**
         * Create a completion for a specific model configuration.
         * @summary Completion Model Config
         * @param {CompletionsApiCreateModelConfigRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createModelConfig(requestParameters: CompletionsApiCreateModelConfigRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CompletionResponse>> {
            const completionModelConfigRequest: CompletionModelConfigRequest = {
                project: requestParameters.project,
                project_id: requestParameters.project_id,
                session_id: requestParameters.session_id,
                session_reference_id: requestParameters.session_reference_id,
                parent_id: requestParameters.parent_id,
                parent_reference_id: requestParameters.parent_reference_id,
                inputs: requestParameters.inputs,
                source: requestParameters.source,
                metadata: requestParameters.metadata,
                source_datapoint_id: requestParameters.source_datapoint_id,
                provider_api_keys: requestParameters.provider_api_keys,
                num_samples: requestParameters.num_samples,
                logprobs: requestParameters.logprobs,
                stream: requestParameters.stream,
                suffix: requestParameters.suffix,
                seed: requestParameters.seed,
                user: requestParameters.user,
                model_config_id: requestParameters.model_config_id
            };
            const localVarAxiosArgs = await localVarAxiosParamCreator.createModelConfig(completionModelConfigRequest, options);
            return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
        },
    }
};

/**
 * CompletionsApi - factory interface
 * @export
 */
export const CompletionsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = CompletionsApiFp(configuration)
    return {
        /**
         * Create a completion by providing details of the model configuration in the request.
         * @summary Create
         * @param {CompletionsApiCreateRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        create(requestParameters: CompletionsApiCreateRequest, options?: AxiosRequestConfig): AxiosPromise<CompletionResponse> {
            return localVarFp.create(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Create a completion using the project\'s active deployment.  The active deployment can be a specific model configuration or an experiment.
         * @summary Completion Deployed
         * @param {CompletionsApiCreateDeployedRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createDeployed(requestParameters: CompletionsApiCreateDeployedRequest, options?: AxiosRequestConfig): AxiosPromise<CompletionResponse> {
            return localVarFp.createDeployed(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Create a completion for a specific experiment.
         * @summary Completion Experiment
         * @param {CompletionsApiCreateExperimentRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createExperiment(requestParameters: CompletionsApiCreateExperimentRequest, options?: AxiosRequestConfig): AxiosPromise<CompletionResponse> {
            return localVarFp.createExperiment(requestParameters, options).then((request) => request(axios, basePath));
        },
        /**
         * Create a completion for a specific model configuration.
         * @summary Completion Model Config
         * @param {CompletionsApiCreateModelConfigRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createModelConfig(requestParameters: CompletionsApiCreateModelConfigRequest, options?: AxiosRequestConfig): AxiosPromise<CompletionResponse> {
            return localVarFp.createModelConfig(requestParameters, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * Request parameters for create operation in CompletionsApi.
 * @export
 * @interface CompletionsApiCreateRequest
 */
export type CompletionsApiCreateRequest = {
    
} & CompletionRequest

/**
 * Request parameters for createDeployed operation in CompletionsApi.
 * @export
 * @interface CompletionsApiCreateDeployedRequest
 */
export type CompletionsApiCreateDeployedRequest = {
    
} & CompletionDeployedRequest

/**
 * Request parameters for createExperiment operation in CompletionsApi.
 * @export
 * @interface CompletionsApiCreateExperimentRequest
 */
export type CompletionsApiCreateExperimentRequest = {
    
} & CompletionExperimentRequest

/**
 * Request parameters for createModelConfig operation in CompletionsApi.
 * @export
 * @interface CompletionsApiCreateModelConfigRequest
 */
export type CompletionsApiCreateModelConfigRequest = {
    
} & CompletionModelConfigRequest

/**
 * CompletionsApiGenerated - object-oriented interface
 * @export
 * @class CompletionsApiGenerated
 * @extends {BaseAPI}
 */
export class CompletionsApiGenerated extends BaseAPI {
    /**
     * Create a completion by providing details of the model configuration in the request.
     * @summary Create
     * @param {CompletionsApiCreateRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof CompletionsApiGenerated
     */
    public create(requestParameters: CompletionsApiCreateRequest, options?: AxiosRequestConfig) {
        return CompletionsApiFp(this.configuration).create(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Create a completion using the project\'s active deployment.  The active deployment can be a specific model configuration or an experiment.
     * @summary Completion Deployed
     * @param {CompletionsApiCreateDeployedRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof CompletionsApiGenerated
     */
    public createDeployed(requestParameters: CompletionsApiCreateDeployedRequest, options?: AxiosRequestConfig) {
        return CompletionsApiFp(this.configuration).createDeployed(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Create a completion for a specific experiment.
     * @summary Completion Experiment
     * @param {CompletionsApiCreateExperimentRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof CompletionsApiGenerated
     */
    public createExperiment(requestParameters: CompletionsApiCreateExperimentRequest, options?: AxiosRequestConfig) {
        return CompletionsApiFp(this.configuration).createExperiment(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Create a completion for a specific model configuration.
     * @summary Completion Model Config
     * @param {CompletionsApiCreateModelConfigRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof CompletionsApiGenerated
     */
    public createModelConfig(requestParameters: CompletionsApiCreateModelConfigRequest, options?: AxiosRequestConfig) {
        return CompletionsApiFp(this.configuration).createModelConfig(requestParameters, options).then((request) => request(this.axios, this.basePath));
    }
}
